﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartHotel.BLL;
using SmartHotel.DAL;
using SmartHotel.Model;

namespace SmartHotel.WebAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HotelInfoController : ControllerBase
    {
        public HotelInfoController(HotelInfoBLL hotelInfoBLL)
        {
            HotelInfoBLL = hotelInfoBLL;
        }

        public HotelInfoBLL HotelInfoBLL { get; }

        //添加
        //1.往上下文的数据集里添加数据(你要添加的对象)
        //2.savechanges
        [HttpPost]
        public int Add(HotelInfo hotelInfo)
        {
            return HotelInfoBLL.Add(hotelInfo);
        }

        //查询 根据id查询酒店信息
        [HttpGet]
        public HotelInfo GetHotelInfoById(int id)
        {
            return HotelInfoBLL.GetHotelInfoById(id);
        }

        //更新
        [HttpPut]
        public int Update(HotelInfo hotelInfo)
        {
            return HotelInfoBLL.Update(hotelInfo);
        }
    }
}
